//
//  SemDetailViewController.m
//  Gradekeeper0.2
//
//  Created by Ben Wu on 11/18/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "SDetailViewController.h"
//#import "Course1h.h"
//#import "Gradekeeper0_2AppDelegate.h"
//#import "Profile.h"
#import <Foundation/NSObject.h>




//SDetailViewController created the sememster table for selected year from SemTableView

@implementation SDetailViewController


//@synthesize coursecontroller;
//Creates the sememsters
-(void)viewDidLoad{
	[super viewDidLoad];
	
	tableList = [[NSMutableArray alloc] init];
	[tableList addObject: @"Fall Sememster"];
	[tableList addObject: @"Spring Sememster"];
	[tableList addObject: @"Summer Sememster"];
	[self setTitle:@"Sememster"];
}



#pragma mark Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}



// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	return [tableList count];
}


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	
	static NSString *CellIdentifier = @"Cell";
	
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
	if (cell == nil) {
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
	}
	
	//set up each cell
	NSUInteger row = [indexPath row];
	cell.textLabel.text = [tableList objectAtIndex:row];
	return cell;
	
}


/*	- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 // Navigation logic may go here. Create and push another view controller.
 // AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
 // [self.navigationController pushViewController:anotherViewController];
 // [anotherViewController release];
		
			NSInteger row = [indexPath row];
			NSString *selectedyear = [NSString stringWithFormat:@"%@", [tableList objectAtIndex:row]];													   
			
			if (self.coursecontroller == nil){
				Course1h *cDetail = [[Course1h alloc] initWithNibName:@"Course1" bundle:nil];
				
				self.coursecontroller = cDetail;
				[cDetail release];
			}
			
			coursecontroller.title = selectedyear;
			
			Profile *profile = [Profile sharedProfile];
			[profile setUserName:selectedyear];
			
			[self.navigationController pushViewController:coursecontroller animated:YES];
			
		}*/
		

/*
 // Override to support conditional editing of the table view.
 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the specified item to be editable.
 return YES;
 }
 */


/*
 // Override to support editing the table view.
 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
 
 if (editingStyle == UITableViewCellEditingStyleDelete) {
 // Delete the row from the data source
 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
 }   
 else if (editingStyle == UITableViewCellEditingStyleInsert) {
 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
 }   
 }
 */


/*
 // Override to support rearranging the table view.
 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
 }
 */


/*
 // Override to support conditional rearranging of the table view.
 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
 // Return NO if you do not want the item to be re-orderable.
 return YES;
 }
 */


- (void)dealloc {
	[super dealloc];
}


@end


